import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
 
   {
    title: '规则名称',
    align:"center",
    dataIndex: 'ruleName'
   },

   {
    title: '状态',
    align:"center",
    dataIndex: 'status',
    customRender:({text}) => {
        return  render.renderDict(text, 'attRuleStatus');
    },
   },
   {
    title: '旧规则名称',
    align:"center",
    dataIndex: 'oldRuleName'
   },

   {
    title: '旧状态',
    align:"center",
    dataIndex: 'oldStatus',
    customRender:({text}) => {
        return  render.renderDict(text, 'attRuleStatus');
    },
   },
   {
    title: '变更类型',
    align:"center",
    dataIndex: 'changeType',
    sorter: {
            multiple: 3,
          },
    filters: [
        { text: '修改', value: 'u' },
        { text: '删除', value: 'd' },
    ],
    customRender: ({ record }) => {
      return record.changeType ? (record.changeType == 'n' ? '新增' :record.changeType == 'u'? '修改':'删除') : '';
    },
   },
   {
    title: '创建人',
    align:"center",
    dataIndex: 'createBy',
    width:100
   },
   {
    title: '创建日期',
    align:"center",
    dataIndex: 'createTime'
   },
   
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "变更类型",
      field: 'changeType',
      component: 'JDictSelectTag',
      componentProps: {
        options: [
         
          { label: '修改', value: 'u' },
          { label: '删除', value: 'd' },
        ],
      },
      //colProps: {span: 6},
 	},
	{
      label: "规则名称",
      field: 'ruleName',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "旧规则名称",
      field: 'oldRuleName',
      component: 'Input',
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '变更类型',
    field: 'changeType',
    component: 'JDictSelectTag',
    componentProps: {
      options: [
        
        { label: '修改', value: 'u' },
        { label: '删除', value: 'd' },
      ],
    },
  },
  {
    label: '规则名称',
    field: 'ruleName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入规则名称!'},
          ];
     },
  },
  {
    label: '上班时间',
    field: 'startTime',
    component: 'Input',
  },
  {
    label: '下班时间',
    field: 'endTime',
    component: 'Input',
  },
  {
    label: '上班刷卡提前多少分钟有效',
    field: 'startUpMins',
    component: 'InputNumber',
  },
  {
    label: '上班刷卡延迟多少分钟有效',
    field: 'startLowerMins',
    component: 'InputNumber',
  },
  {
    label: '下班刷卡提前多少分钟有效',
    field: 'endUpMins',
    component: 'InputNumber',
  },
  {
    label: '下班刷卡延迟多少分钟有效',
    field: 'endLowerMins',
    component: 'InputNumber',
  },
  {
    label: '晚到多少分钟不算迟到',
    field: 'lateMins',
    component: 'InputNumber',
  },
  {
    label: '早退多少分钟不算早退',
    field: 'earlyMins',
    component: 'InputNumber',
  },
  {
    label: '迟到多少分钟算旷工',
    field: 'lateAbsMins',
    component: 'InputNumber',
  },
  {
    label: '早退多少分钟算旷工',
    field: 'earlyAbsMins',
    component: 'InputNumber',
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"attRuleStatus"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入状态!'},
          ];
     },
  },
  {
    label: '旧规则名称',
    field: 'oldRuleName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入旧规则名称!'},
          ];
     },
  },
  {
    label: '旧上班时间',
    field: 'oldStartTime',
    component: 'Input',
  },
  {
    label: '旧下班时间',
    field: 'oldEndTime',
    component: 'Input',
  },
  {
    label: '旧上班刷卡提前多少分钟有效',
    field: 'oldStartUpMins',
    component: 'InputNumber',
  },
  {
    label: '旧上班刷卡延迟多少分钟有效',
    field: 'oldStartLowerMins',
    component: 'InputNumber',
  },
  {
    label: '旧下班刷卡提前多少分钟有效',
    field: 'oldEndUpMins',
    component: 'InputNumber',
  },
  {
    label: '旧下班刷卡延迟多少分钟有效',
    field: 'oldEndLowerMins',
    component: 'InputNumber',
  },
  {
    label: '旧晚到多少分钟不算迟到',
    field: 'oldLateMins',
    component: 'InputNumber',
  },
  {
    label: '旧早退多少分钟不算早退',
    field: 'oldEarlyMins',
    component: 'InputNumber',
  },
  {
    label: '旧迟到多少分钟算旷工',
    field: 'oldLateAbsMins',
    component: 'InputNumber',
  },
  {
    label: '旧早退多少分钟算旷工',
    field: 'oldEarlyAbsMins',
    component: 'InputNumber',
  },
  {
    label: '旧状态',
    field: 'oldStatus',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"attRuleStatus"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入旧状态!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  createBy: {title: '创建人',order: 0,view: 'text', type: 'string',},
  createTime: {title: '创建日期',order: 1,view: 'datetime', type: 'string',},
  changeType: {title: '变更类型',order: 2,view: 'list', type: 'string',},
  ruleName: {title: '规则名称',order: 3,view: 'text', type: 'string',},
  startTime: {title: '上班时间',order: 4,view: 'text', type: 'string',},
  endTime: {title: '下班时间',order: 5,view: 'text', type: 'string',},
  status: {title: '状态',order: 14,view: 'list', type: 'string',},
  oldRuleName: {title: '旧规则名称',order: 15,view: 'text', type: 'string',},
  oldStartTime: {title: '旧上班时间',order: 16,view: 'text', type: 'string',},
  oldEndTime: {title: '旧下班时间',order: 17,view: 'text', type: 'string',},
  oldStatus: {title: '旧状态',order: 26,view: 'list', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
